package com.prs.crm.service.oa.impl;

import java.io.File;
import java.util.Collection;
import java.util.Date;

import com.prs.crm.context.AppContext;
import com.prs.crm.context.Attach;
import com.prs.crm.context.Constrains;
import com.prs.crm.context.FileUtil;
import com.prs.crm.dao.oa.ScheduleDao;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.oa.Schedule;
import com.prs.crm.service.impl.BaseServiceImpl;
import com.prs.crm.service.oa.ScheduleService;

public class ScheduleServiceImpl extends BaseServiceImpl<Schedule,ScheduleDao> implements ScheduleService{

	@Override
	public void saveSchedule(Schedule schedule, File file, String fileName) {
		// TODO Auto-generated method stub
	
		
		Attach attach = FileUtil.getInstance().saveFile(file, fileName, "", Constrains.UPLOAD_DIR_SCHEDULE);
		if(attach.getSrc() != null) {
			schedule.setAttach(attach.getSrc());
		}
		schedule.setAllotPerson(AppContext.getAccountContext().getUser());
		this.getDao().save(schedule);
	}

	@Override
	public Collection<Schedule> getExecuteSchedule(Person person) {
		// TODO Auto-generated method stub
		return this.getDao().getExecuteSchedule(person);
	}

	@Override
	public Collection<Schedule> getAuditSchedule(Person person) {
		// TODO Auto-generated method stub
		return this.getDao().getAuditSchedule(person);
	}

	@Override
	public Collection<Object[]> getScheduleReportDataSouce(String state,
			Date datestart, Date dateend, Collection<Person> persons) {
		// TODO Auto-generated method stub
		return this.getDao().getScheduleReportDataSouce(state, datestart, dateend, persons);
	}

	@Override
	public Collection<Schedule> getOverdueSchedule(Person person) {
		// TODO Auto-generated method stub
		return this.getDao().getOverdueSchedule(person);
	}

	@Override
	public Collection<Schedule> getExecuteScheduleByLevel(Person person,
			String level) {
		// TODO Auto-generated method stub
		return this.getDao().getExecuteScheduleByLevel(person,level);
	}

}
